package org.op.service.nav;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;

import org.op.service.WwDocumentInfo;
import org.op.service.WwInfoObject;

public class FilesystemTreeModel extends DefaultTreeModel {

	public FilesystemTreeModel(TreeNode rootNode) {
		super(rootNode);
	}
	
	/**
	 *  Empty folders need to show up as folders, not leafs! 
	 *  
	 */
	public boolean isLeaf(Object node) {
		boolean leaf = false;
		if (node instanceof DefaultMutableTreeNode) {
			WwInfoObject wwInfo = (WwInfoObject) ((DefaultMutableTreeNode)node).getUserObject();
			if (wwInfo instanceof WwDocumentInfo) {
				leaf = true;
			}
		}
		
		return leaf;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -411329122911369444L;

}
